import React from 'react';
import {
  View,
  Text,
  TouchableOpacity,
} from 'react-native';

import BaseItem from '../common/BaseItem';
import TImage from '../../components/TImage';
import SizeUtils from '../../common/SizeUtils';
import Config from '../../config';

export default class JifenDuihuanItemView extends BaseItem {
  constructor(props) {
    super(props);

    this._itemWidth = SizeUtils.getWindowSize().width/2;
    this._itemHeight = SizeUtils.translateDesignWidthToCode(294) + SizeUtils.translateDesignHeightToCode(200);
  }

  render() {
    return (
      <TouchableOpacity style={{width:this._itemWidth,
          height:this._itemHeight,
          paddingTop:SizeUtils.translateDesignHeightToCode(23),
          paddingBottom:SizeUtils.translateDesignHeightToCode(20),
          borderColor:"#eeeeee", borderBottomWidth:SizeUtils.translateDesignNumToCode(3),
          borderRightWidth:(this.props.index%2 === 0) ? SizeUtils.translateDesignNumToCode(3) : 0,
          flexDirection:"column", alignItems:"center"}}
          onPress={this._onPressItem.bind(this)}>
        <TImage style={{width:294, height:294}} isMini={true}
          source={{uri:this.props.data.image_url}}
          />
        <View style={{width:this._itemWidth, paddingLeft:SizeUtils.translateDesignWidthToCode(40),
            backgroundColor:"#00000000",}}>
          <Text style={{backgroundColor:"#00000000",
              fontSize:SizeUtils.translateFontSizeToCode(32),
              color:"#000000",
              paddingTop:SizeUtils.translateDesignHeightToCode(21)}} numberOfLines={1}>
            {this.props.data.name}
          </Text>
          <Text style={{backgroundColor:"#00000000",
              fontSize:SizeUtils.translateFontSizeToCode(28),
              color:"#999999", paddingTop:SizeUtils.translateDesignHeightToCode(10)}} numberOfLines={1}>
            {this.props.data.desc}
          </Text>
          <View style={{backgroundColor:"#00000000",
              flexDirection:"row", alignItems:"center",
              paddingTop:SizeUtils.translateDesignHeightToCode(10)}}>
            <Text style={{fontSize:SizeUtils.translateFontSizeToCode(40),
                color:"#db3132"}}>
                {this.props.data.price}
            </Text>
            <Text style={{fontSize:SizeUtils.translateFontSizeToCode(28),
                backgroundColor:"#00000000", color:"#999999"}}>
              {" 积分 还剩" + (this.props.data.total - this.props.data.buy_num) + "件"}
            </Text>
          </View>
        </View>
      </TouchableOpacity>
    )
  }

  _onPressItem() {
    this.gotoPage(Config.pages.jifenmall_duihuan_item_content, {itemData:this.props.data});
  }
}
